package com.hrms.hrms_security.utils;

import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SourceStringReader;

import java.io.File;
import java.io.OutputStream;
import java.nio.file.Files;

public class PlantUmlRenderer {
    public void render(String source, String filename) {
        File file = new File("E:/anything/picture/" + filename);
        System.out.println("PlantUML源码：" + source);
        try {

            OutputStream os = Files.newOutputStream(file.toPath());
            new SourceStringReader(source).outputImage(os, new FileFormatOption(FileFormat.PNG));
            os.close();
        } catch (Exception e) {
            System.out.println("PlantUML渲染失败：" + e);
        }
    }
}
